/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package data;

import entities.ArtPhoto;
import java.util.LinkedList;

/**
 *
 * @author bertram
 */
public class ImageCache {

    private static LinkedList<ArtPhoto> photos = new LinkedList<ArtPhoto>();

    public static synchronized void addPhoto(ArtPhoto pht)
    {
        photos.add(pht);
        if(photos.size()>100) photos.removeFirst();
    }

    public static ArtPhoto getPhoto(int photoID)
    {
        for(ArtPhoto pht: photos)
        {
            if(pht.getImageID() == photoID) return pht;
        }
        return new ArtPhoto(photoID);
    }
    public static boolean contains(int photoID)
    {
        boolean contains = false;
        for(ArtPhoto p: photos)
        {
            if(p.getImageID() == photoID) return true;
        }
        return contains;
    }
}
